@extends('master')

@section('content')



@include('menu')

    <div class="container">
      <div class="panel panel-default mgt_10">
        <div class="panel-heading">
          <h3 class="panel-title">今日资源单</h3>
        </div>
        <div class="panel-body">
          {{--<p class="typetag">--}}
            {{--<b>产品类型：</b> <a href="">坯布<span class="badge">42</span></a> <a href="">棉纱<span class="badge">42</span></a> <a href="">色布<span class="badge">42</span></a> <a href="">棉花<span class="badge">42</span></a>--}}
          {{--</p>--}}
          <hr class="hr_dot">
          <a href="/sources/upload" class="btn btn-primary btn-sm pull-right"><i class="fa fa-upload"></i> 上传资源单</a>
          <form class="form-inline">
            {{--<div class="form-group">--}}
              {{--<label for="exampleInputName2">选择类型：</label>--}}
              {{--<select class="form-control input-sm">--}}
                {{--<option>坯布</option>--}}
                {{--<option>棉纱</option>--}}
                {{--<option>色布</option>--}}
                {{--<option>棉花</option>--}}
              {{--</select>--}}
            {{--</div>--}}
            <div class="form-group">
              <label for="exampleInputEmail2">&nbsp品种：</label>
              <input type="email" class="form-control input-sm" id="exampleInputEmail2" placeholder="请输入品种关键词">
            </div>
            &nbsp<button type="submit" class="btn btn-warning btn-sm"><i class="fa fa-search"></i> 搜索</button>
          </form>


        </div>
      </div>

      <div role="tabpanel">

        <!-- Nav tabs -->
        <ul class="nav nav-tabs" role="tablist">
          <li role="presentation" class="active"><a href="#all" aria-controls="all" role="tab" data-toggle="tab">全部资源</a></li>
          <li role="presentation"><a href="#myfollow" aria-controls="myfollow" role="tab" data-toggle="tab">我关注的</a></li>
        </ul>

        <!-- Tab panes -->
        <div class="tab-content">
          <div role="tabpanel" class="tab-pane active" id="all">
            <table class="table table-hover">
              <thead>
                <tr>
                  <th><input type="checkbox" id="checkall" /> 公司名</th><th>上传者</th><th>大类</th><th>主营品种</th><th>资源单说明</th><th>下载数</th><th>上传时间</th><th>操作</th>
                </tr>
              </thead>
              <tbody>
              @foreach($sources as $source)
                <tr>
                  <td><input type="checkbox" name="checkname" /> {{ $source->user->company }}</td><td>{{ $source->user->name }} <a title="关注他" onclick="follow({{ $source->user->id }})" href="javascript:void(0)"><i id="heart_{{ $source->user->id }}" @if(in_array($source->user->id,$follows)) class="fa fa-heart" @else class="fa fa-heart-o" @endif></i></a></td><td>坯布</td><td>有弹 无弹</td><td>常规品种</td><td>{{ $source->download }}</td><td>{{ $source->created_at }}</td><td><a target="_blank" href="{{ route('sources.show',$source->id) }}"><i class="fa fa-eye"></i> 预览</a> <a target="_blank" href="{{ route('sources.download',$source->id) }}" ><i class="fa fa-file-excel-o"></i> 下载</a></td>
                </tr>
               @endforeach

              </tbody>
            </table>
          </div>
          <div role="tabpanel" class="tab-pane" id="myfollow">
            <table class="table table-hover">
              <thead>
                <tr>
                  <th><input type="checkbox" id="checkall" /> 公司名</th><th>上传者</th><th>大类</th><th>主营品种</th><th>资源单说明</th><th>下载数</th><th>上传时间</th><th>操作</th>
                </tr>
              </thead>
              <tbody>
              @foreach($follow_sources as $source)
                <tr>
                  <td><input type="checkbox" name="checkname" /> {{ $source->user->company }}</td><td>{{ $source->user->name }} <a title="关注他" onclick="follow({{ $source->user->id }})" href="javascript:void(0)"><i id="heart_{{ $source->user->id }}" @if(in_array($source->user->id,$follows)) class="fa fa-heart" @else class="fa fa-heart-o" @endif></i></a></td><td>坯布</td><td>有弹 无弹</td><td>常规品种</td><td>{{ $source->download }}</td><td>{{ $source->created_at }}</td><td><a target="_blank" href="{{ route('sources.show',$source->id) }}"><i class="fa fa-eye"></i> 预览</a> <a target="_blank" href="{{ route('sources.download',$source->id) }}" ><i class="fa fa-file-excel-o"></i> 下载</a></td>
                </tr>
               @endforeach
            </tbody>
            </table>
          </div>
        </div>

      </div>



    </div><!-- /.container -->
    <script>
    function follow(user_id){
        $('#heart_'+user_id).addClass('fa-spinner fa-pulse');
        $.get('{{ Route('follow') }}',{user_id:user_id},function(data){
            if(data == 'follow'){
                $('#heart_'+user_id).removeClass('fa-spinner');
                $('#heart_'+user_id).removeClass('fa-pulse');
                $('#heart_'+user_id).removeClass('fa-heart-o');
                $('#heart_'+user_id).addClass('fa-heart');
            }else if(data == 'unfollow'){
                $('#heart_'+user_id).removeClass('fa-spinner');
                $('#heart_'+user_id).removeClass('fa-pulse');
                $('#heart_'+user_id).removeClass('fa-heart');
                $('#heart_'+user_id).addClass('fa-heart-o');
            }else if('unsignin' == data){
                window.location.href='{{ route('signin') }}'
            }
        })
    }
    </script>
@stop